<template>
	<view class="content padding">
		<view class="padding ffffff border_2 margin_bottom3" v-for="item in list.data" :key="item.id">
			<view class="flexbetween padding_bottom border_bottom_dotted">
				<view class="color_san text_w">
					{{date(item.createtime)}}
				</view>
				<view class="text_w">
					<text style="color: #FD463E;" v-if="item.state==1">待处理</text>
					<text style="color: #FD463E;" v-if="item.state==2">待改进</text>
					<text style="color: #50B674;" v-if="item.state==3">已处理</text>
				</view>
			</view>
			<view class="margin_top color_san text_a">
				{{item.content}}
			</view>
			<view class="margin_top flexleft flex_wrap padding_bottom border_bottom_solid" v-if="item.images_arr.length">
				<view class="imgBox" v-for="value in item.images_arr">
					<image :src="value" mode="widthFix"></image>
				</view>
			</view>
			<view class="margin_top color_san text_c" v-if="item.state==2||item.state==3">
				<!-- {{item.reply}} -->
				<u-parse :content="item.reply"></u-parse>
			</view>
		</view>
		<view class="flexcenter placeholderBoxTop" v-if="!list.data.length">
			<image class="placeholderBox" src="/static/placeholderimg.png" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				list: {
					data: []
				}
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				httpRequest.request("/api/user/feedback_list", 'GET', {
					page: page || 1,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						console.log(_this.imgUrl)
						res.data.data.forEach(item => {
							item.images = item.images.split(',')
							_this.$set(item,"image_arr",[])
							// item.images.forEach(value => {
							// 	value = _this.imgUrl + value
							// })
						})
						res.data.data.forEach(item => {
							item.images.forEach(value => {
								value = _this.imgUrl + value
								item.image_arr.push(value)
							})
						})
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = res.data
							_this.list.data = resList.data;
						}
						console.log(_this.list.data);
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.border_bottom_dotted {
		border-bottom: 5rpx dotted rgba(153, 153, 153, 1);
	}

	.imgBox {
		width: 25%;
		height: 124rpx;
		display: flex;
		justify-content: center;

		image {
			width: 124rpx;
			height: 100%;
			border-radius: 12rpx;
		}
	}

	.border_bottom_solid {
		border-bottom: 1rpx solid rgba(153, 153, 153, .1);
	}
</style>